<template>
    <div>
        <eagle-dialog title="请选择拜访单位" @confirm="confirm" @open="onOpen" ref="eagleDialog" v-bind="$attrs" v-on="$listeners">
            <div class="dialog-content-radio">
                <eagle-radio-group   style="height:500px;overflow:scroll" v-model="VisitUnit" direction="horizontal">
                    <div
                        v-for="(item, index) in data.VisitUnitList"
                        :key="index"
                        style="margin-bottom: 10px"
                        :style="{ width: (item.CompanyCode && item.CompanyCode!='0') ? '50%' : '100%' }"
                        >
                        <eagle-radio v-if="item.CompanyCode && item.CompanyCode!='0'" :name="item.CompanyCode">
                            <span style="font-size: 14px">{{ item.CompanyName }}</span>
                        </eagle-radio>
                    </div>
                </eagle-radio-group>
            </div>
        </eagle-dialog>
    </div>
</template>
<script>
//选择检查类型弹框
import eagleRadio from '../../../components/eagle/eagle-radio.vue';
export default {
  components: { eagleRadio },
    name:"check-type-dialog",
    props:{
        data: {},
    },
    data(){
        return {
            VisitUnit: "",
        }
    },
    methods:{
        confirm(){
            let result ={};
            if (this.VisitUnit!=undefined) {
                if (this.VisitUnit != "") {
                    result=  this.data.VisitUnitList.find(n=>n.CompanyCode==this.VisitUnit)
                }
                this.$emit("close", result);
            }
        },
        onOpen() {
            console.log(this.data)
            if (this.data.VisitUnit) {
               var result=  this.data.VisitUnitList.find(n=>n.CompanyName==this.data.VisitUnit)
                this.VisitUnit = result.CompanyCode;
            }
        },
    }
}
</script>
<style lang="less" scoped>
.dialog-content-radio {
    padding: 0 15px;
}
</style>